<?php echo $this->render('/public/header');?>
<?php use yii\helpers\Url;?>
<div id="main" class="col-xs-12">
	<div class="form-inline">
		<form method="get">
			<div class="form-group" style="margin-left:5px">
				<input value="<?php echo yii::$app->request->get('begin_time')?yii::$app->request->get('begin_time'):date('Y-m')."-01";?>" 
				type="text" name="begin_time" class="layui-input"  onclick="layui.laydate({elem: this})">
			</div>
			<div class="form-group" style="margin-left:5px"><input type="text" name="end_time" class="layui-input" 
				value="<?php echo yii::$app->request->get('end_time')?yii::$app->request->get('end_time'):date('Y-m-d');?>" 
				onclick="layui.laydate({elem: this})">
			</div>
			<div class="form-group" style="margin-left:5px">
				<input type="text" id="service_name" class="layui-input" value="<?php echo yii::$app->request->get('service_name');?>" placeholder="搜索invocie编号">
			</div>
			<div class="form-group" style="margin-left:5px">
				<input type="text" id="customer_name" class="layui-input" value="<?php echo yii::$app->request->get('customer_name');?>" placeholder="搜索客户">
			</div>
			<div class="form-group" style="margin-left:5px">
				<input type="text" id="service_name" class="layui-input" value="<?php echo yii::$app->request->get('service_name');?>" placeholder="搜索业务员">
			</div>
			<button class="btn btn-success btn-small" style="margin-left: 5px">搜索</button>
		</form>
	</div>
	<br/>
	<table class="table table-bordered">
		<thead>
			<tr>
				<th>id</th>
				<th>日期</th>
				<th>工厂信息</th>
				<th>产品</th>
				<th>退回金额</th>
				<th>退税率</th>
				<th>是否已收工厂发票</th>
				<th style="width:100px">操作</th>
			</tr>
		</thead>
		<tbody>
			<?php foreach ($this->params['list'] as $k => $v) { ?>
			<tr>
				<td><?php echo $v['id'];?></td>
				<td><?php echo $v['date'];?></td>
				<td><?php echo $v['factory'];?></td>
				<td><?php echo $v['product'];?></td>
				<td><?php echo $v['return_money'];?></td>
				<td><?php echo $v['return_rate'];?>%</td>
				<td><?php if($v['invocie']){echo '是';}else{echo '否';};?></td>
				<td><a class="layui-btn layui-btn-mini layui-btn-normal">编辑</a>
					<a class="layui-btn layui-btn-mini layui-btn-danger" href="javascript:void(0)" onclick="del_rebate(<?php echo $v['id'];?>)">删除</a>
				</td>
			</tr>
			<?php } ?>
		</tbody>
	</table>
	<div id="page"></div>
</div>
<script>
	function del_rebate(v)
	{
		if(layer.confirm('确认删除',{},function(){
			var url = "<?php echo Url::to(['table/del_rebate']);?>"
			$.post(url,{id:v},function(res){
				if(res.code==1){
					layer.confirm(res.msg,{},function(){
						window.location.reload();
					})
				}else
				{
					layer.alert(res.msg);
				}
			},'json')
		}));
	}
	layui.laypage({
		cont: 'page' 
		,pages: <?php echo $this->params['page']['page'];?>
		,curr:<?php echo $this->params['page']['curr'];?>
		,skin: '#5FB878'
		,skip: true 
		,jump: function(obj, first){
			if(!first){
				window.location.href="<?php echo $this->params['page']['base_url'];?>&p="+obj.curr;
			}
		}
	});

</script>
<?php echo $this->render('/public/footer');?>